package com.yingdong.logic.domain;

import com.yingdong.db.User;
import com.yingdong.logic.controller.HouseController;
import com.yingdong.logic.controller.ItemController;
import com.yingdong.logic.controller.PetController;
import com.yingdong.logic.controller.ResourceController;

public class GameUser {
	private User usr;
	private int sessionId;
	private int userId;

	////////////// controller////////////////////
	private ResourceController resourceController;
	private PetController petController;
	private HouseController houseController;
	private ItemController itemController;

	public GameUser() {
		resourceController = new ResourceController(this);
		petController = new PetController(this);
		houseController = new HouseController(this);
		itemController = new ItemController(this);
	}

	public void init() {
		resourceController.init();
		petController.init();
		houseController.init();
		itemController.init();
	}

	public void saveToDb() {
		resourceController.saveDB();
		petController.saveDB();
		houseController.saveDB();
		itemController.saveDB();
	}

	public void firstEnter() {
		resourceController.firstEnter();
		petController.firstEnter();
		houseController.firstEnter();
		itemController.firstEnter();
	}

	public void onUpdate(int dt) {
		resourceController.onUpdate(dt);
		petController.onUpdate(dt);
		houseController.onUpdate(dt);
		itemController.onUpdate(dt);
	}

	public PetController getPetController() {
		return petController;
	}

	public HouseController getHouseController() {
		return houseController;
	}

	public ResourceController getResourceController() {
		return resourceController;
	}

	public User getUsr() {
		return usr;
	}

	public void setUsr(User usr) {
		this.usr = usr;
	}

	public int getSessionId() {
		return sessionId;
	}

	public void setSessionId(int sessionId) {
		this.sessionId = sessionId;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

}
